home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / progtool / c / egem_210 / egem / example / windemo / hello.c < prev    next >
C/C++ Source or Header  |  1995-11-25  |  2KB  |  76 lines

  1.  
  2. /* einfaches "Hello world!"-Beispielprogramm, läuft nur als Programm */
  3.  
  4. #include <e_gem.h>
  5. #include <string.h>
  6.  
  7. #define GADGETS    NAME|CLOSER|FULLER|MOVER|SIZER|SMALLER
  8.  
  9. WIN *win;
  10. char text[] = "Hello fäns! Hir ei äm!";
  11.  
  12. void Draw(WIN *win,GRECT *rect)
  13. {
  14.     rc_sc_clear(rect);
  15.     v_gtext(x_handle,win->work.g_x+gr_cw,win->work.g_y+gr_ch,text);
  16. }
  17.  
  18. int Init(XEVENT *event,int available)
  19. {
  20.     return((MU_MESAG|MU_KEYBD) & available);
  21. }
  22.  
  23. int Event(XEVENT *event)
  24. {
  25.     int *msg = event->ev_mmgpbuf,wich = event->ev_mwich;
  26.  
  27.     if ((wich & MU_KEYBD) && (event->ev_mmokstate & K_CTRL) && scan_2_ascii(event->ev_mkreturn,K_CTRL)=='Q')
  28.         exit_gem(0);
  29.  
  30.     if (wich & MU_MESAG)
  31.     {
  32.         switch (msg[0])
  33.         {
  34.         case AP_TERM:
  35.         case WM_CLOSED:
  36.             exit_gem(0);
  37.             break;
  38.         case WM_TOPPED:
  39.             window_top(win);
  40.             break;
  41.         case WM_BOTTOMED:
  42.             window_bottom(win);
  43.             break;
  44.         case WM_FULLED:
  45.             *(GRECT *) &msg[4] = win->fulled ? win->prev : win->max;
  46.         case WM_SIZED:
  47.         case WM_MOVED:
  48.             window_size(win,(GRECT *) &msg[4]);
  49.             break;
  50.         default:
  51.             return(0);
  52.         }
  53.     }
  54.  
  55.     return (MU_MESAG & wich);
  56. }
  57.  
  58. void main(void)
  59. {
  60.     GRECT curr;
  61.     int x,y,d;
  62.     if (init_gem(NULL,"Hello!","HELLO",0,0,0)==TRUE)
  63.     {
  64.         graf_mkstate(&x,&y,&d,&d);
  65.         window_border(GADGETS,x,y,gr_cw*((int) sizeof(text)+1),gr_ch*3,&curr);
  66.         if ((win=open_window("Hello!",NULL,NULL,NULL,GADGETS,FALSE,0,0,NULL,&curr,NULL,Draw))!=NULL)
  67.         {
  68.             v_set_mode(MD_REPLACE);
  69.             v_set_text(ibm_font_id,ibm_font,BLACK,NULL);
  70.             Event_Handler(Init,Event);
  71.             Event_Multi(NULL);
  72.         }
  73.     }
  74.     exit_gem(-1);
  75. }
  76.